
//引入工具模块
import {getNewsList} from '../../utils/util'
//调用工具模块的函数获取所有新闻
Page({
  data: {
    // 轮播图图片的路径
    swiperImages: [
      { src: 'https://i0.hdslb.com/bfs/archive/0e2d27bd811ebf432bc1acebaece26c15cab79d4.jpg'},
      { src: 'https://q0.itc.cn/images01/20241106/21f0fec50c1149da88db3e3ed9bde2d8.jpeg'},
      { src: 'https://i0.hdslb.com/bfs/archive/e3231ebdc4e24a773c422add9ef21139a99e22f4.jpg'}
    ],
    //给新闻列表赋值
    list:[ ]
  },
  onLoad() {
    const newsList = getNewsList();
    this.setData({
      list: newsList
    });
    console.log(this.data.list);
  },
  //自定义函数：跳转到新闻详情
  goToDetail:function(event){
    //获得新闻id
    console.log(event.currentTarget.dataset.id);
    let id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/newsDetail/newsDetail?id=${id}`
    });
  }

 
})